clearvars -except Globaloption option 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This code reads in the VAR dynamics and produce the Campbell-Shiller decomposition in the paper
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Load data
loaddata_4CIjoint_annual;
ttime = [startdate:enddate];

if exist('option', 'var') == 0
    option.robust = 1;
end

if option.robust == 1
    output_rp = 0.03;
elseif option.robust == 2
    output_rp = 0.02;
end

run ../../tools/cs_estimation;

%% steady-state upper bound calculation
upper = exp(pxbar) * (mean(taxrevgdp - spendgdp));
gdpreturn = output_rp + y0nom_1 + yspr0 - pi0;

if option.robust==1
    save MAT/UKprepara_30.mat k0x k1x s upper pdX pxbar gdpreturn
elseif option.robust==2
    save MAT/UKprepara_20.mat k0x k1x s upper pdX pxbar gdpreturn gdebt
end